package com.glory.gloryquickui.activity

import android.os.Bundle
import com.glory.gloryquickui.R
import com.glory.gloryquickui.base.BaseActivity
import com.glory.gloryquickui.viewmodel.HomeViewModel
import com.glory.hiwork.mvvm.bean.ToastMessageBean
import kotlinx.android.synthetic.main.activity_home.*

/**
 * FileName: HomeActivity
 * Author: XJH
 * Date: 2021/5/27 10:46
 * Description:
 * History:
 */
class HomeActivity : BaseActivity<HomeViewModel>() {
    override fun layoutId(): Int {
        return R.layout.activity_home
    }

    override fun initView(savedInstanceState: Bundle?) {
        viewModel.getHomeInfo(this)
    }

    override fun initData() {
        viewModel.defUI.callObserve.observe(this){
            when(it.type){
                404 ->{
                    viewModel.defUI.toastEvent.value = ToastMessageBean("传递数据为空,请联系系统管理员",false)
                }
                200 ->{
                    tabLayout.setTabData(viewModel.mTabEntities, this, R.id.content, viewModel.mFragments)
                }
            }
        }
    }
}